package com.example.mylazyviewpager;

import android.util.Log;
import android.view.View;
import android.widget.TextView;

import com.example.mylazyviewpager.base.LazyFragment1;

public class MyFragment1 extends LazyFragment1 {
    private final String TAG = "MyFragment1";

    private TextView textView;
    private int index = -1;
    public MyFragment1(int index) {
        super(index);
        this.index = index;
    }

    @Override
    protected void initView(View rootView) {
        Log.e(TAG, "initView: " + index);
        if (rootView != null){
            textView = rootView.findViewById(R.id.textView);
        }
    }

    @Override
    protected int getLayoutRes() {
        int layoutResId = R.layout.fragment_1_layout;
        switch (index) {
            case 1:
                layoutResId = R.layout.fragment_1_layout;
                break;
            case 2:
                layoutResId = R.layout.fragment_2_layout;
                break;
            case 3:
                layoutResId = R.layout.fragment_3_layout;
                break;
            case 4:
                layoutResId = R.layout.fragment_4_layout;
                break;
            case 5:
                layoutResId = R.layout.fragment_5_layout;
                break;
        }
        return layoutResId;
    }

    @Override
    protected void onFragmentLoad() {
        super.onFragmentLoad();
        Log.e(TAG, "onFragmentLoad: " );
        textView.setText("加载成功");
    }

    @Override
    protected void onFragmentStopLoad() {
        super.onFragmentStopLoad();
        Log.e(TAG, "onFragmentStopLoad: " );
        textView.setText("停止加载");
    }
}
